#include "widget.h"

Widget::Widget(QWidget *parent): QWidget(parent)
{
    setFixedSize(640, 480);
    pushButton = new QPushButton("start", this);
    pushButton->move(10, 10);
    worker = new Worker();
    worker->moveToThread(&workerThread);
    connect(pushButton, &QPushButton::clicked, worker, &Worker::dosomething);
    connect(worker, SIGNAL(Send_Frame(cv::Mat)), this, SLOT(Img_Show(cv::Mat)));
    connect(worker, &Worker::Task_Finished, &workerThread, &QThread::quit);
    workerThread.start();
}

void Widget::Img_Show(cv::Mat f)
{
    cv::imshow("cameta", f);
    cv::waitKey(10);
}

Widget::~Widget()
{
    workerThread.quit();
    workerThread.wait();
    std::cout<<"Thread finished successfully."<<std::endl;
}
